<?php
/* @var $this ToolsController */
/* @var $model Tools */
/* @var $form CActiveForm */
$alertClass = Yii::app()->basePath.'/views/calendar/confirmationAlert.php';
require_once($alertClass);
?>
<?php
Yii::app()->clientScript->registerScript('login', "
	$(function(){
		if($('.errorSummary').html() != undefined) {
			$('#dialogError').dialog('open');
		}
	});
");
?>
<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'tools-form',
	'enableAjaxValidation'=>false,
)); ?>


	<?php	$this->beginWidget('zii.widgets.jui.CJuiDialog', array( 
		'id'=>'dialogError',
		'options'=>array(
			'autoOpen'=>false,
			'modal'=>true,
			'buttons'=>array('Ok' => 'js:function() { $(this).dialog(\'close\'); }'),
			'width'=>'auto',
			'height'=>'auto',
			'resizable'=>false
		),
	));
	echo $form->errorSummary($model);
	$this->endWidget(); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'name'); ?>
		<?php echo $form->textField($model,'name',array('size'=>45,'maxlength'=>45)); ?>
	</div>

	<div class="row buttons">
		<?php 
		if($model->isNewRecord)
			echo CHtml::submitButton('Utwórz', array('id'=>'createButton'));
		else
			echo CHtml::submitButton('Zapisz', array('onclick'=>'return confirmationAlert(event);'));
		?>
	</div>

<?php $this->endWidget(); ?>
<script type="text/javascript">
function confirmationAlert(event){
	event.preventDefault();
	$.confirm({
        'title'		: editAlert.title,
        'message'	: editAlert.message,
        'buttons'	: {
            'Tak'	: {
                'class'	: 'blue',
                'action': function(){
                	$("#tools-form").submit();
                }
            },
            'Nie'	: {
                'class'	: 'gray',
                'action': function(){
                	
                    }	// Nothing to do in this case. You can as well omit the action property.
            }
        }
    });	
}
</script>
</div><!-- form -->